package com.chen.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chen.dto.SetmealDto;
import com.chen.entity.Setmeal;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealMapper extends BaseMapper<Setmeal> {

    @Select("select setmeal.*,category.name as categoryName " +
            "from setmeal , category where setmeal.category_id=category.id " +
            "limit #{page},#{pagesize}")
    List<SetmealDto> selectPage(@Param("page")int page, @Param("pagesize")int pagesize);

    @Select("select setmeal.*,category.name as categoryName " +
            "from setmeal , category where setmeal.category_id=category.id " +
            "and setmeal.name like CONCAT('%',#{name},'%')limit #{page},#{pagesize}")
    List<SetmealDto> selectPageWithName(@Param("page")int page, @Param("pagesize")int pagesize, @Param("name") String name);

}
